var TOKEN = uni.getStorageSync('TOKEN') //TOKEN

const request = (options) => {

	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: "https://hazardouswastewxapi.cnsbdz.com/v2uploadfile/upload", //上传图片api
			filePath: options.filePath,
			name: options.name || 'file',
			header: {
				"token": uni.getStorageSync("TOKEN")
			},
			success: (res) => {
				console.log(res.data, 'res');
				let data = JSON.parse(JSON.stringify(res.data))
				console.log(typeof data, JSON.parse(data))
				if (JSON.parse(data).code == 0) {
					resolve(JSON.parse(data))
					uni.showToast({
						title: "上传成功",
						icon: "none",
					})
				} else {
					uni.showToast({
						title: "上传失败",
						icon: "error",
					})
				}

			},
			fail(reject) {
				uni.showToast({
					title: "上传失败",
					icon: "none",
				})
				console.log(reject, 'reject');
			}
		});




	})
}








export default request